package com.zhouwd.zcamera;

import android.media.AudioFormat;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;

import java.io.IOException;

public class AudioEncode {

    private String MIME_TYPE="audio/mp4a-latm";
    private int KEY_CHANNEL_COUNT = 2;
    private int KEY_SAMPLE_RATE = 44100;
    private int KEY_BIT_RATE = 64000;
    private int KEY_AAC_PROFILE = MediaCodecInfo.CodecProfileLevel.AACObjectLC;
    private int WAIT_TIME = 10000;

    private int AUDIO_FORMAT = AudioFormat.ENCODING_PCM_16BIT;
    private int CHANNEL_MODE = AudioFormat.CHANNEL_IN_STEREO;

    private int BUFFFER_SIZE = 2048;

    private MediaCodec mEncoder;

    public AudioEncode() throws IOException {

        mEncoder = MediaCodec.createEncoderByType(MIME_TYPE);
        MediaFormat mediaFormat = MediaFormat.createAudioFormat(MIME_TYPE, KEY_SAMPLE_RATE, KEY_CHANNEL_COUNT);
        mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, KEY_BIT_RATE);
        mediaFormat.setInteger(MediaFormat.KEY_AAC_PROFILE, KEY_AAC_PROFILE);
        mEncoder.configure(mediaFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);

    }

}
